package jdbc2;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDBCDemo2 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "20030501");
        Statement stmt = conn.createStatement();
        /*
        * 向insert表中插入一条记录
        * INSERT INTO userinfo(username,password,nickname,age) VALUES
        * ("GGBond",123456,"猪猪侠","18");
        * */
        String sql = "INSERT INTO userinfo(username,password,nickname,age) VALUES\n" +
                "(\"EEBond\",123456,\"乔伊\",\"18\");";
        int num = stmt.executeUpdate(sql);
        if (num>0){
            System.out.println("插入成功");
        }
        System.out.println(num);
        conn.close();
    }
}
